var PATH_PREFIX ="";

function setPathPrefix(path){
	PATH_PREFIX =  path;
}
$(function(){
	WASP_WIDGET.initializeSelectStyle();
	WASP_WIDGET.registerResetClearEvent();
	WASP_WIDGET.triggerDateStyleWithYMD("#beginDate1");
	WASP_WIDGET.triggerDateStyleWithYMD("#endDate1");
    WASP_WIDGET.triggerCustInfoSelect("custNo1");
    WASP_WIDGET.triggerDictionarySelect("custType","CUST_TYPE");
});

var $custInfoReportList = $('#custInfoReportList');

$(function() {
	$custInfoReportList.jqGrid({   
		url:PATH_PREFIX + 'custInfoListPage.do', 
		/*caption:'客户信息列表<button type="button" class="btn btn-default btn-sm btn-small btn-fullscreen" title="" tabindex="-1"><i class="fa fa-arrows-alt icon-fullscreen"></i></button>',*/  
		datatype: "json",
		colNames:["id", "客户名称","客户类型","客户账号","银行账号","地址","联系方式","联系人","联系人地址","联系人联系方式","专业投资者"],        
		colModel:[  { name: 'custNo', index: 'custNo', key: true, hidden:true },       
		            { name: 'custName', index: 'custName', width: 50, resizable: true, sortable: false },
		            { name: 'custTypeName', index: 'custTypeName', width: 20, resizable: true, sortable: false },
		            { name: 'custNo', index: 'custNo', width: 20, resizable: true, sortable: false },
		            { name: 'bankacco', index: 'bankacco', width: 30, resizable: true, sortable: false },
		            { name: 'address', index: 'address', width: 70, resizable: true, sortable: false },
		            { name: 'contactWay', index: 'contactWay', width: 20, resizable: true, sortable: false },
		            { name: 'contactName', index: 'contactName', width: 20, resizable: true, sortable: false },
		            { name: 'contactAddr', index: 'contactAddr', width: 70, resizable: true, sortable: false },
		            { name: 'contactTel', index: 'contactTel', width: 30, resizable: true, sortable: false },
		            { name: 'invprtp', index: 'invprtp', width: 30, resizable: true, sortable: false }
				  ],
		rowNum: 20,
        rowList: [20, 30, 50],
        rownumbers: true,
        rownumWidth: 50,
        postData: {},
        prmNames: { search: "search", page: "pageNo", rows: "limit" },
        height: 'auto',
        width: false,
        autowidth:true,
        editurl: '',
        viewrecords: true,
        cellEdit: false,
        shrinkToFit: true,
        grouping: false,
        jsonReader: {
            root: "items", //结果集
            records: "total", //总记录数 
            total: "pageCount", //总页数
            page: "pageNo", //当前页 
            repeatitems: false // (4) 
        },  
		multiselect:false,
		pager: "#custInfoReportListPage",						
		viewrecords: true,
		hidegrid: false, 
		gridComplete: function(){
			var ids = $custInfoReportList.jqGrid('getDataIDs');
			for(var i = 0;i < ids.length;i++){
				var rowId = ids[i];
				$custInfoReportList.jqGrid('setRowData', ids[i]);
			}	
		}
	});
	$custInfoReportList.navGrid('#custInfoReportListPage',{edit:false,add:false,del:false,search:false,refreshstate:'current'});
	$custInfoReportList.jqGrid('setFrozenColumns');
	jqGridResize($custInfoReportList);
});

//绑定回车事件,查询
$("body").keypress(function(event){
	var key = event.which;
	if(key == "13"){
		queryByCondtion(true);
	}
});


function queryByCondtion1(flag) {
	var beginDate1 = $.trim($("#beginDate1").val());   
	var endDate1   = $.trim($("#endDate1").val());   
	var custNo1    = $.trim($("#custNo1").val()); 
	var custType = $.trim($("#custType").val()); 
	var postData = $custInfoReportList.jqGrid("getGridParam", "postData");
    $.extend(postData, {
        'sp[beginDate]':beginDate1,
        'sp[endDate]':endDate1,
        'sp[custType]':custType,
        'sp[custNo]':custNo1
    });
    if (flag) {
    	$custInfoReportList.jqGrid("setGridParam",{"datatype": "json"}).trigger("reloadGrid", [{ page: 1 }]); //重新载入Grid表格
    } else {
    	$custInfoReportList.jqGrid("setGridParam",{"datatype": "json"}).trigger("reloadGrid"); //重新载入Grid表格
    }
}

